import java.util.Scanner;
// https://www.acwing.com/problem/content/4/
public class bag03 {
    // 多重背包问题1
    static int [] v1  = new int[10010];
    static int [] w1  = new int[10010];
    public static void main(String [] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int v = sc.nextInt();
        int cnt = 1;
        for(int i = 0 ; i < n ; i ++)
        {
            int vi = sc.nextInt();
            int wi = sc.nextInt();
            int si = sc.nextInt();
            for(int k = 1; k <= si ; k ++)
            {
                v1[cnt] = vi;
                w1[cnt] = wi;
                cnt ++;
            }
        }
        int [] dp = new int[v+2];
        for(int i = 1; i < cnt ; i ++)
        {
            for(int j = v ; j >= 0 ; j --)
            {
                if(j >= v1[i])
                    dp[j] = Math.max(dp[j],dp[j-v1[i]] + w1[i]);
            }
        }
        System.out.print(dp[v]);
    }
}
